#pragma  once

//#include "LogDefine.h"
//#include "LogUtil.h"

#include "PortUtility.h"

namespace LineDisplayImp
{
	typedef enum _ELineDisplayType
	{
		EUnknownLineDisplay = -1,
		VC220,
		ELineDsiplayTypeCount
	}ELineDisplayType;
	const static CString LineDisplayName[ELineDsiplayTypeCount + 1] = {
		_T("VC220"),
		_T("None")
	};

	class CLineDisplayImp
	{
	public:
		CLineDisplayImp();
		virtual ~CLineDisplayImp();
		virtual void InitPort(int nPort, int nParity = 2, int nBaud = 9600, ELineDisplayType eType = VC220) 
		{ 
			m_portInfo.nPortIndex = nPort; 
			m_portInfo.nParity = nParity;
			m_portInfo.nBoudRate = nBaud;
			m_eType = eType;
		}

		virtual void Initialize() = 0;

		virtual void InitPort(const PortUtility::Serial_Port_Info &portInfo) {m_portInfo = portInfo;}

		// Methods	V1.12
		virtual int Open();
		virtual int Close();

		// Need to add claim and release methods.
		virtual void ClearDescriptors() = 0;
		virtual void ClearText() = 0;
		//	virtual void CreateWindow(int nVRow, int nVCol, int nVHeight, int nVWidth, int nWinHeight, int nWinWidth) = 0;
		virtual void DestroyWindow() = 0;
		virtual void DefineGlyph(int nGlyphCode, int nGlyph) = 0;
		virtual void DisplayBitmap(wstring strFileName, int nWidth, int nAlignmentX, int nAlignmentY) = 0;
		virtual void DisplayText(wstring strData, int nAttribute) = 0;
		virtual void DisplayTextAt(int nRow, int nCol, wstring strData, int nAttribute) = 0;
		virtual void ReadCharacterAtCursor(int &nData) = 0;
		virtual void RefreshWindow(/*int nWindow = 0*/) = 0;
		virtual void ScrollText(int nDirection, int nUnits) = 0;
		virtual void SetBitmap(int nBitmapNumber, wstring strFileName, int nWidth, int nAlignmentX, int nAlignmentY) = 0;
		virtual void SetDescriptor(int nDescriptor, int nAttribute) = 0;

		// Nonstandard
		virtual void ScrollTextEx(wstring strData, int nDirection, int nUnits) = 0;

		// Properties
	public:
		_declspec(property(get = GetCursorColumn))	int CursorColumn;
		_declspec(property(get = GetCursorRow))  int CursorRow;
		_declspec(property(get = GetType)) ELineDisplayType Type;

	public:
		int GetCursorColumn() { return m_nCursorCol; }
		int GetCursorRow() { return m_nCursorRow; }
		ELineDisplayType GetType() {return m_eType;}

	protected:
		PortUtility::Serial_Port_Info m_portInfo;
		int m_nCursorCol;
		int m_nCursorRow;
		int m_nError;
		ELineDisplayType m_eType;
	};
}





